package com.ruoyi.btlfbreed.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.btlfbreed.domain.TbChickenSalesInfo;
import com.ruoyi.btlfbreed.service.ITbChickenSalesInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 肉鸡销售Controller
 * 
 * @author codeman
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/btlfbreed/chickenSalesInfo")
public class TbChickenSalesInfoController extends BaseController
{
    @Autowired
    private ITbChickenSalesInfoService tbChickenSalesInfoService;

    /**
     * 查询肉鸡销售列表
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenSalesInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbChickenSalesInfo tbChickenSalesInfo)
    {
        startPage();
        List<TbChickenSalesInfo> list = tbChickenSalesInfoService.selectTbChickenSalesInfoList(tbChickenSalesInfo);
        return getDataTable(list);
    }

    /**
     * 导出肉鸡销售列表
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenSalesInfo:export')")
    @Log(title = "肉鸡销售", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbChickenSalesInfo tbChickenSalesInfo)
    {
        List<TbChickenSalesInfo> list = tbChickenSalesInfoService.selectTbChickenSalesInfoList(tbChickenSalesInfo);
        ExcelUtil<TbChickenSalesInfo> util = new ExcelUtil<TbChickenSalesInfo>(TbChickenSalesInfo.class);
        util.exportExcel(response, list, "肉鸡销售数据");
    }

    /**
     * 获取肉鸡销售详细信息
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenSalesInfo:query')")
    @GetMapping(value = "/{saleId}")
    public AjaxResult getInfo(@PathVariable("saleId") Long saleId)
    {
        return success(tbChickenSalesInfoService.selectTbChickenSalesInfoBySaleId(saleId));
    }

    /**
     * 新增肉鸡销售
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenSalesInfo:add')")
    @Log(title = "肉鸡销售", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbChickenSalesInfo tbChickenSalesInfo)
    {
        return toAjax(tbChickenSalesInfoService.insertTbChickenSalesInfo(tbChickenSalesInfo));
    }

    /**
     * 修改肉鸡销售
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenSalesInfo:edit')")
    @Log(title = "肉鸡销售", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbChickenSalesInfo tbChickenSalesInfo)
    {
        return toAjax(tbChickenSalesInfoService.updateTbChickenSalesInfo(tbChickenSalesInfo));
    }

    /**
     * 删除肉鸡销售
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenSalesInfo:remove')")
    @Log(title = "肉鸡销售", businessType = BusinessType.DELETE)
	@DeleteMapping("/{saleIds}")
    public AjaxResult remove(@PathVariable Long[] saleIds)
    {
        return toAjax(tbChickenSalesInfoService.deleteTbChickenSalesInfoBySaleIds(saleIds));
    }
}
